package com.ruiyeclub.controller;

import com.ruiyeclub.entity.Menu;
import com.ruiyeclub.entity.MenuVO;
import com.ruiyeclub.mapper.MenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @author Ray。
 * @create 2020-03-05 14:54
 */
@RestController
@RequestMapping("/menu")
public class MenuHandler {

    @Value("${server.port}")
    private String port;

    @Autowired
    @SuppressWarnings("all")
    private MenuMapper menuMapper;

    @GetMapping("/index")
    public String index(){
        return this.port;
    }

    @GetMapping("/findAll/{index}/{limit}")
    public MenuVO findAll(@PathVariable("index") int index, @PathVariable("limit") int limit){
        List<Menu> list = menuMapper.findAll(index, limit);
        int count = menuMapper.count();
        return new MenuVO(0,"",count,list);
    }
}